package cards;

public class Card implements Comparable<Card>, ICard{
	
	private final int mySuit;
	private final int myRank;
	private String myName;
	
	private static final String[] suitStrings = {
		"dummy", "spades", "hearts", "diamonds", "clubs"	
	};
	
	private static final String[] rankStrings = {
		"dummy","dummy","two","three","four","five",
		"six","seven","eight","nine","ten",
		"jack","queen","king","ace"	
	};
	
	//normal construction of a card
	public Card(int suit, int rank){
		mySuit = suit;
		myRank = rank;
		myName = rankStrings[getRank()]+" of "+
	             suitStrings[getSuit()];
	}
	
	//default constructor creates "dummy" card
	public Card(){
		mySuit = 0;
		myRank = 0;
		myName = rankStrings[getRank()]+" of "+
				 suitStrings[getSuit()];
	}
	
	public int getSuit() {
		return mySuit;
	}
	
	public int getRank() {
		return myRank;
	}
	
	public String toString(){
		return myName;
	}
	
	public int compareTo(Card c) {
 
		int source = getRank() + (getSuit() * 13);
		int dest = c.getRank() + (c.getSuit() * 13);
		
		return dest - source;
		
	}
	
	public boolean equals(Card c){
	    return compareTo(c) == 0;
	}
	
	public boolean isSameSuit(Object o){
		ICard other = (ICard) o;
		return this.getSuit() == other.getSuit();
	}
	
}